﻿#region Copyright and License Notice
// Copyright (C)2010-2016 - Rob Levine and other contributors
// http://configgen.codeplex.com
// 
// This file is part of ConfigGen.
// 
// ConfigGen is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// ConfigGen is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License and 
// the GNU Lesser General Public License along with ConfigGen.  
// If not, see <http://www.gnu.org/licenses/>
#endregion

using System;
using System.Xml.Serialization;
using ConfigGen.Core;

namespace ConfigGen.ConsoleApp.Core
{
    /// <summary>
    /// Extends the config gen execution settings class with further settings that are only relevant when being used in the console application
    /// </summary>
    [Serializable]
    public class ConsoleAppPreferences : Preferences
    {
        /// <summary>
        /// True to cause the console application to return a non-zero exit code if any warnings were raised during configuration generation, otherwise false.
        /// </summary>
        public bool ErrorOnWarnings { get; set; }

        /// <summary>
        /// True to cause the console application to return a non-zero exit code if any files are changed during configuration generation, otherwise false.
        /// </summary>
        public bool ErrorOnFileChanged { get; set; }

        /// <summary>
        /// Converts an object into its XML representation.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Xml.XmlWriter"/> stream to which the object is serialized. </param>
        public override void SerializeToXml(System.Xml.XmlWriter writer)
        {
            var serializer = new XmlSerializer(typeof(ConsoleAppPreferences));
            serializer.Serialize(writer, this);
        }
    }
}
